const arr = [' 1234 ', '123', '123 '];
function map() {
    const result = [];
    for(let i = 0; i < arr.length; i++) {
        result.push(arr[i].trim());
    }

    return result;
}

Array.prototype.map = function (fn: Function) {
    const resultArr = [];

    for (const val of this) {
        resultArr.push(fn(val));
    }

    return resultArr;
}